
#ifndef _DEFINITIONS_
#define _DEFINITIONS_

#include <stdlib.h>

//--- TTG setting ---

//If it is defined, some checks will be performed (e.g. division by zero, recieving NULL, etc).
//Otherwise, it can crash.
#define TTG_DEBUG

//Defines, that pipeline is monitored by PipeVisualizer.
#define TTG_PL_VISUALIZER

//Requires to include "using namespace ..." for all namespaces.
//#define TTG_USING_NAMESPACES

//--- Used technologies ---

//Requires to use Intel Threading Building Blocks library for low-level multithreading.
//#define INTEL_TBB

//Allows to use references to DirectX SDK. Otherwise they will be removed.
//Can be useful for separate usage of Common and Runtime.Low libs.
//#define MICROSOFT_DIRECTX

//Allows to use NVidia PhysX. Otherwise all references to PhysX (includes and libs) will be removed.
//#define NVIDIA_PHYSX

//#define NVIDIA_CUDA

#define SAFE_DELETE(object)	\
{							\
	if (object != NULL)		\
	{						\
		delete object;		\
		object = NULL;		\
	}						\
}

#define SAFE_RELEASE(object)		\
{									\
	if ((object) != NULL)			\
	{								\
		(object)->Release();		\
		object = NULL;				\
	}								\
}

#define SAFE_DELETE_ARRAY(arr)	\
{								\
	if (arr != NULL)			\
	{							\
		delete[] arr;			\
		arr = NULL;				\
	}							\
}

#ifndef __CUDACC__

template <class Container>
inline void SAFE_DELETE_CONTENT(Container *container)
{
	if (container != NULL)
	{
		Container::iterator it = container->begin();
		while (it != container->end())
		{
			if (*it != NULL)
				delete *it;
			it++;
		}
		container->clear();
	}
}

#define SAFE_RELEASE_CONTENT(container, type)		\
{													\
	if (container != NULL)							\
	{												\
		type::iterator it = (container)->begin();	\
		while (it != (container)->end())			\
		{											\
			if (*it != NULL)						\
				(*it)->Release();					\
			it++;									\
		}											\
		(container)->clear();						\
	}												\
}

#endif

namespace ttg
{
	//Contains information about version of the ttgLib.
	class Version
	{
		public:
			//Major number of the version (e.g. 0, 1, etc).
			static const int major;
			//Minor number of the version (e.g. 01, 02, 10, etc).
			static const int minor;
			//Suffex of the version (e.g. a1, pa1, b2).
			static const char * const suffix;
			//Returns fromatted version (e.g. "0.01-pa4").
			static const char *toString();
	};
}

#endif
